﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Redirect</title>
    <link href="~/Content/css/Redirect.css" rel="stylesheet" />
    <script type="text/javascript">
        function GetRequest(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return decodeURIComponent(r[2]); return null;
        }

        function clock() {
            i = i - 1;
            switch (GetRequest('RedirectType').toLowerCase()) {
                case "close": { document.title = "页面将在 " + i + " 秒后关闭."; break; }
                case "redirect": { document.title = "页面将在 " + i + " 秒后跳转."; break; }
                case "home": { document.title = "页面将在" + i + "秒后跳转到主页!"; break; }
                case "none": { document.title = GetRequest('msg'); break; }//GetRequest('msg').replace(/<[^>]*>/g, ' ')
                default: { document.title = "页面将在" + i + " 秒后关闭."; break; }
            }

            if (i > 0) {
                setTimeout("clock();", 1000);
            }
            else {
                switch (GetRequest('RedirectType').toLowerCase()) {//GetRequest('action')
                    case "close":
                        {
                            self.opener = null;
                            window.open("", "_self");
                            self.close();
                            break;
                        }
                    case "redirect":
                        {
                            top.location.href = GetRequest('RedirectUrl');//GetRequest('url')
                            break;
                        }
                    case "home":
                        {
                            top.location.href = '/';
                            break;
                        }
                    case "none": { break; }
                    default:
                        {
                            self.opener = null;
                            window.open("", "_self");
                            self.close();
                            break;
                        }
                }
            }
        }
        var i = 3;
        clock();
    </script>
</head>
<body>
    <!-- 如果需要跳转，请传入 Url 参数的时候先进行 Uri.EscapeDataString() 编码 -->
    <h1 id="logo" style="text-align: center">
        <img src="/Images/logo.png" />
    </h1>
    <p>
        <script type="text/javascript">
           document.write(GetRequest('msg'));
            document.write('<br/>');
            switch (GetRequest('RedirectType').toLowerCase()) {
                case "close": { document.write('页面即将关闭 …'); break; }
                case "redirect": { document.write('页面即将跳转…'); break; }
                case "home": { document.write('页面即将跳转…'); break; }
                case "none": { break; }
                default: { document.write('页面即将关闭 …'); break; }
            }
        </script>
    </p>
    <h2>
    </h2>
</body>
</html>
<!--
参数:

action[close(default), redirect, home] : 行为，有关闭，跳转和回到首页，默认为关闭
msg : 提示信息
url = 如果选择了跳转，必须传入地址

-->
